package com.solairen.myapplication.Pager

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.solairen.myapplication.MainActivity
import com.solairen.myapplication.Pager.LoginPager.LoginNameActivity


const val PREFS_NAME = "LoginPrefs"
const val PREF_USERNAME = "username"
const val PREF_PASSWORD = "password"
const val PREF_LOGGED_IN = "isLoggedIn"
const val KEY_NAME = "LoginPrefs_username"
const val KEY_PWD = "LoginPrefs_password"
const val KEY_LOGIN_STATUS = "isLoggedIn"

/**
 * 欢迎页

 */
class SplashActivity : AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        init()
    }

    private fun init() {
        val sp = getSharedPreferences(PREFS_NAME, MODE_PRIVATE)
        if (sp.getBoolean(PREF_LOGGED_IN, false)) {
            // 已经登录，直接进入首页
            startActivity(Intent(this, MainActivity::class.java))
        } else {
            // 还未登录，进入登录页
            startActivity(Intent(this, LoginNameActivity::class.java))
        }
        finish()
    }
}